/**
 *******************************************************************************
 * @FileName  : hci_api.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-09-10
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms desc ribed
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */
#ifndef HCI_TR_API_H_
#define HCI_TR_API_H_

#include "stack/ble_types.h"
#include "utils/byte_stream.h"
#include "utils/fifo.h"
#include "utils/assert.h"

/*! HCI Transport Enable/Disable */
#ifndef HCI_TR_EN
#define HCI_TR_EN            0
#endif

/*! Enable Ring buffer. */
#define HCI_RINGBUF_EN       0

/*! HCI transport layer protocol selection. */
#define HCI_TR_H4            0
#define HCI_TR_H5            1
#define HCI_TR_USB           2
#define HCI_TR_MODE          HCI_TR_H4

/*! HCI UART transport pin define */
#define HCI_TR_UART_ID       UART1
#define HCI_TR_UART_IRQn     UART1_IRQn
#define HCI_TR_UART_DMA_TX   DMAC_Peripheral_UART1_Tx
#define HCI_TR_UART_DMA_RX   DMAC_Peripheral_UART1_Rx
#define UART_IRQHandler      UART1_IRQHandler
#define HCI_TR_RX_PIN        GPIO_P07
#define HCI_TR_TX_PIN        GPIO_P06
#define HCI_TR_BAUDRATE      (115200)

/*! HCI UART transport Flow Control. */
#define HCI_TR_FLOW_CTRL_EN  0
#if HCI_TR_FLOW_CTRL_EN
/*** RTS/CTS Pin ***/
#define HCI_TR_RTS_PIN       UART_RTS_PB3
#define HCI_TR_CTS_PIN       UART_CTS_PB3
/*** RTS ***/
#define HCI_TR_RTS_INVERT    1 /*!< 0: RTS PIN will change from low to high. !! use for RTS auto mode(default auto mode)*/
#define HCI_TR_RTS_THRESH    5 /*!< RTS trigger threshold. range: 1-16. */
/*** CTS ***/
#define HCI_TR_CTS_POLARITY  1 /*!< 0: low level stop TX; 1: high level stop TX.*/
#endif


/*! HCI transport layer API. */

/**
 * @brief : HCI transport initialization.
 * @param : none.
 * @param : none.
 */
void HCI_TR_Init(void);

/**
 * @brief : HCI transport main loop.
 * @param : none.
 * @param : none.
 */
void HCI_TR_TaskStart(void);

/**
 * @brief : HCI IRQ handler.
 * @param : none.
 * @param : none.
 */
void HCI_TR_IRQHandler(void);


#endif /* HCI_TR_API_H_ */
